package com.hiultra.archive.service.impl;

import java.util.List;

import com.hiultra.archive.domain.SimfExamine;
import com.hiultra.archive.mapper.SimfExamineItemMapper;
import com.hiultra.common.constant.UserConstants;
import com.hiultra.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hiultra.archive.mapper.SimfExamineSetupMapper;
import com.hiultra.archive.domain.SimfExamineSetup;
import com.hiultra.archive.service.ISimfExamineSetupService;

/**
 * 审批步骤Service业务层处理
 * 
 * @author ls
 * @date 2023-09-25
 */
@Service
public class SimfExamineSetupServiceImpl implements ISimfExamineSetupService 
{
    @Autowired
    private SimfExamineSetupMapper simfExamineSetupMapper;

    /**
     * 查询审批步骤
     * 
     * @param setupId 审批步骤主键
     * @return 审批步骤
     */
    @Override
    public SimfExamineSetup selectSimfExamineSetupBySetupId(Long setupId)
    {
        return simfExamineSetupMapper.selectSimfExamineSetupBySetupId(setupId);
    }

    /**
     * 查询审批步骤列表
     * 
     * @param simfExamineSetup 审批步骤
     * @return 审批步骤
     */
    @Override
    public List<SimfExamineSetup> selectSimfExamineSetupList(SimfExamineSetup simfExamineSetup)
    {
        return simfExamineSetupMapper.selectSimfExamineSetupList(simfExamineSetup);
    }

    /**
     * 新增审批步骤
     * 
     * @param simfExamineSetup 审批步骤
     * @return 结果
     */
    @Override
    public int insertSimfExamineSetup(SimfExamineSetup simfExamineSetup)
    {
        return simfExamineSetupMapper.insertSimfExamineSetup(simfExamineSetup);
    }

    /**
     * 修改审批步骤
     * 
     * @param simfExamineSetup 审批步骤
     * @return 结果
     */
    @Override
    public int updateSimfExamineSetup(SimfExamineSetup simfExamineSetup)
    {
        return simfExamineSetupMapper.updateSimfExamineSetup(simfExamineSetup);
    }

    /**
     * 批量删除审批步骤
     * 
     * @param setupIds 需要删除的审批步骤主键
     * @return 结果
     */
    @Override
    public int deleteSimfExamineSetupBySetupIds(Long[] setupIds)
    {
        return simfExamineSetupMapper.deleteSimfExamineSetupBySetupIds(setupIds);
    }

    /**
     * 删除审批步骤信息
     * 
     * @param setupId 审批步骤主键
     * @return 结果
     */
    @Override
    public int deleteSimfExamineSetupBySetupId(Long setupId)
    {
        return simfExamineSetupMapper.deleteSimfExamineSetupBySetupId(setupId);
    }

    /**
     * 校验审批步骤名称是否唯一
     *
     * @param simfExamineSetup 审批步骤
     * @return 结果
     */
    @Override
    public String checkExamineSetupNameUnique(SimfExamineSetup simfExamineSetup){
        Long setupId = StringUtils.isNull(simfExamineSetup.getSetupId()) ? -1L : simfExamineSetup.getSetupId();
        SimfExamineSetup info = simfExamineSetupMapper.checkExamineSetupNameUnique(simfExamineSetup);
        if (StringUtils.isNotNull(info) && info.getSetupId().longValue() != setupId.longValue()) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }


    /**
     * 校验审批步骤排序是否唯一
     *
     * @param simfExamineSetup 审批步骤
     * @return 结果
     */
    @Override
    public String checkExamineSortNoUnique(SimfExamineSetup simfExamineSetup){
        Long setupId = StringUtils.isNull(simfExamineSetup.getSetupId()) ? -1L : simfExamineSetup.getSetupId();
        SimfExamineSetup info = simfExamineSetupMapper.checkExamineSortNoUnique(simfExamineSetup);
        if (StringUtils.isNotNull(info) && info.getSetupId().longValue() != setupId.longValue()) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }
}
